﻿Public Class ChiTietHoaDonDAO
    Public Shared Sub Insert(ByVal ctpx As ChiTietHoaDonDTO)
        Dim strSQL As String

        strSQL = "Insert into CHITIETHOADONBAN(MACHITIETHOADONBAN,MAMATHANG, MAHOADONBAN,SOLUONGBAN,DONGIABAN) values(" & ctpx.MaChiTietHoaDon & ",'" & ctpx.MaMatHang & "'," & ctpx.MaHoaDonBan & "," & ctpx.SoLuongBan & "," & ctpx.DONGIABAN & ")"
        SQLProvider.ExecNoneQuery(strSQL)

    End Sub
    Public Shared Function selectall(ByVal MaHoaDon As String) As DataTable
        Dim strSQl As String
        strSQl = "select * from CHITIETHOADONBAN WHERE MAHOADONBAN = '" & MaHoaDon & "'"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQl)
        Return dt
    End Function
    Public Shared Sub delete(ByVal MaHoaDon As String)
        Dim strSQL As String
        strSQL = "delete from CHITIETHOADONBAN where MACHITIETHOADONBAN = '" & MaHoaDon & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function MaTuTang() As Integer
        Dim strSQl As String
        Dim a As DataTable
        Dim b As Integer
        strSQl = "select count(MACHITIETHOADONBAN) from CHITIETHOADONBAN"
        a = SQLProvider.ExecQuery(strSQl)
        b = a.Rows(0).Item(0).ToString()
        Return b + 1
    End Function
End Class
